/*
 * @Description:
 * @Author: maxyang
 * @Date: 2022-06-05 17:41:49
 * @LastEditTime: 2022-06-28 20:33:03
 * @LastEditors: liutq
 * @Reference:
 */
package admin

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"github.com/maxyang107/jinglan/common"
	"github.com/maxyang107/jinglan/model/user"
	"github.com/maxyang107/jinglan/service"
)

func Login(c *gin.Context) {
	var usermsg user.User

	if err := c.ShouldBind(&usermsg); err != nil {
		common.ResponseToJson(http.StatusOK, common.ParamError, err.Error(), c)
		return
	}
	token, err2 := service.UserService.CheckAdminLogin(&usermsg)
	if err2 != nil {

		common.ResponseToJson(http.StatusOK, common.Fail, err2.Error(), c)
		return
	}
	common.ResponseDetailToJson(http.StatusOK, token, "登录成功", c)
}
